#include "core/transform.hpp"

Matrix transforms::identity()
{
  return Matrix(1,0,0,0,
		0,1,0,0,
		0,0,1,0,
		0,0,0,1);
}

Matrix transforms::translate(const Vector& d)
{
  return Matrix(1,0,0,d.x,
		0,1,0,d.y,
		0,0,1,d.z,
		0,0,0,1);
}

Matrix transforms::scale(const Vector& s)
{
  return Matrix(s.x,0,0,0,
		0,s.y,0,0,
		0,0,s.z,0,
		0,0,0,1);
}

//BORROWED FROM PBRT
Matrix transforms::rotatex(const float angle)
{
  float sin_t = sinf(radians(angle));
  float cos_t = cosf(radians(angle));
  return Matrix(1,     0,      0, 0,
		0, cos_t, -sin_t, 0,
		0, sin_t,  cos_t, 0,
		0,     0,      0, 1);
}

//BORROWED FROM PBRT
Matrix transforms::rotatey(const float angle)
{
  float sin_t = sinf(radians(angle));
  float cos_t = cosf(radians(angle));
  return Matrix( cos_t,   0,  sin_t, 0,
		 0,   1,      0, 0,
		 -sin_t,   0,  cos_t, 0,
		 0,   0,   0,    1);
}

//BORROWED FROM PBRT
Matrix transforms::rotatez(const float angle)
{
  float sin_t = sinf(radians(angle));
  float cos_t = cosf(radians(angle));
  return Matrix(cos_t, -sin_t, 0, 0,
                sin_t,  cos_t, 0, 0,
                0,      0, 1, 0,
                0,      0, 0, 1);
}
